package com.oxygen.design.singleton.bean;

/**
 * @author wangjie
 * @title: SingleObjectDCL
 * @description: 双检锁/双重校验锁（DCL，即 double-checked locking）
 * @date 2022/3/30 10:01
 **/
public class SingleObjectDCL {

    private volatile static SingleObjectDCL singleton;

    private SingleObjectDCL() {
    }

    public static SingleObjectDCL getSingleton() {
        if (singleton == null) {
            synchronized (SingletonEnum.class) {
                if (singleton == null) {
                    singleton = new SingleObjectDCL();
                }
            }
        }
        return singleton;
    }

    public void showMessage() {
        System.out.println("Hello World!");
    }
}
